﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using Ajeelee.Core.Utils;
using FxhjpgWeb.Business;
using FxhjpgWeb.Model;
using FxhjpgWeb.WebSite.Code;

namespace FxhjpgWeb.WebSite.en.pfdn
{
    public partial class newsinfo : PageBase
    {
        protected int id;
        protected News info;
        protected string cname;
        INewsBusiness newsBll = new NewsBusinessFactory().CreateNewsBusiness();

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            // 获取参数
            id = QueryParamInt32("id");

            if (id > 0)
            {
                try
                {
                    // 读取新闻信息
                    info = newsBll.GetById(id);
                    if (info != null)
                    {
                        // 点击统计
                        Hashtable table = new Hashtable();
                        table.Add(NewsHash.Id, id);
                        table.Add(NewsHash.Count, info.Count + 1);
                        newsBll.UpdateSomeVal(table);

                        //当前分类
                        var citem = Utility.GetNewsClass().FirstOrDefault(c => c.Id == info.CId);
                        if (citem != null)
                        {
                            cname = citem.Name;
                        }
                    }
                }
                catch (Exception ex)
                {
                    Function.WriteErrorLog(ex);
                }
            }
            if (info == null)
            {
                info = new News();
                Page_GoTo("/en/404.aspx");
            }
        }
    }
}